package com.qxgl.qxglt.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;

import org.hibernate.annotations.GenericGenerator;

import lombok.Data;
@Data
@Table
@Entity
@GenericGenerator(name = "jpa-uuid",strategy = "uuid")
public class Roles {
    @Id
    @GeneratedValue(generator = "jpa-uuid")
    @Column(length = 32)
	private String id;//角色编号
	@Column(unique = true,nullable = false)
    private String name;//角色名称
   
    // 角色相关用户
    @JsonIgnore	
	@ManyToMany(cascade = CascadeType.REFRESH,mappedBy = "rolesList",fetch = FetchType.LAZY)
	private List<Users> usersList;
    // 角色相关模块
    @ManyToMany(cascade = CascadeType.REFRESH)
	@JoinTable(name = "role_module", inverseJoinColumns = @JoinColumn(name = "module_id"), joinColumns = @JoinColumn(name = "role_id"))
	private List<Modules> modulesList;


    
}